<?php
/**
 * @author spenceryg
 * @date 2022/4/18
 * @time 4:37 下午
 * @focus love & life
 */


namespace app\common\lib\mysql;


use app\common\lib\mysql\interfaces\TableModifyExecute;
use think\facade\Db;
use think\facade\Log;

class TpTableModify extends TableModify implements TableModifyExecute
{

    /**
     * execute
     * @throws \Exception
     */
    public function execute()
    {
        try {
            $sql_arr = explode("\r\n", $this->sql);
            foreach ($sql_arr as $sql){
                Db::execute($sql);
            }
            if ($this->new_table_name){
                $this->table_name = $this->new_table_name;
                $this->new_table_name = '';
            }
        } catch (\Exception $e) {
            Log::error($e);
            throw $e;
        }

    }
}
